#pragma once

#include <string>
#include <Windows.h>
#include "errors.h"

using namespace std;

class MappedFile
{
public:
	friend class MapIterator;
	MappedFile( wstring strFileName , long lSizeOfBuffer );
	~MappedFile(void);
	MapIterator Begin();
	MapIterator End();
private:
	char* m_pBuffer;
	HANDLE m_hFile;
	HANDLE m_hFileMapping;
	long m_lSizeOfBuffer;
	long m_lFileSize;
	long m_lShift; // - number of part of file
	void MapFilePart( long lShift ); // lShift - number of part of file
	char GetCharFromFile( long lPos );
};


class MapIterator
{
public:
	MapIterator() {}
	MapIterator( MappedFile* mapf , long pointer );
	~MapIterator() {}
	char operator*();
	void operator++();
	bool operator == (MapIterator const& i);
    bool operator != (MapIterator const& i);
	MapIterator& operator =(const MapIterator& other);
private:
	MappedFile* pMap;
	long m_pointer;
};